<template>
  <div class="app-container">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-left">
        <h2>定时任务管理</h2>
        <p>管理系统定时任务，包括每月15号更新可提现金额等定时任务</p>
      </div>
      <div class="header-actions">
        <el-button type="primary" icon="el-icon-refresh" @click="loadTaskList">刷新</el-button>
      </div>
    </div>

    <!-- 定时任务概览卡片 -->
    <el-row :gutter="20" class="overview-cards">
      <el-col :span="6">
        <el-card class="overview-card running">
          <div class="card-content">
            <div class="card-icon">
              <i class="el-icon-video-play"></i>
            </div>
            <div class="card-info">
              <div class="card-value">{{ jobStats.running }}</div>
              <div class="card-label">运行中</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="overview-card stopped">
          <div class="card-content">
            <div class="card-icon">
              <i class="el-icon-video-pause"></i>
            </div>
            <div class="card-info">
              <div class="card-value">{{ jobStats.stopped }}</div>
              <div class="card-label">已停止</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="overview-card error">
          <div class="card-content">
            <div class="card-icon">
              <i class="el-icon-warning"></i>
            </div>
            <div class="card-info">
              <div class="card-value">{{ jobStats.error }}</div>
              <div class="card-label">异常</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="overview-card total">
          <div class="card-content">
            <div class="card-icon">
              <i class="el-icon-s-operation"></i>
            </div>
            <div class="card-info">
              <div class="card-value">{{ jobStats.total }}</div>
              <div class="card-label">总任务</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 搜索筛选 -->
    <el-card class="search-card" shadow="never">
      <el-form :model="searchForm" :inline="true" class="search-form">
        <el-form-item label="定时任务名称">
          <el-input v-model="searchForm.jobName" placeholder="输入定时任务名称" clearable style="width: 200px;"></el-input>
        </el-form-item>
        <el-form-item label="定时任务状态">
          <el-select v-model="searchForm.status" placeholder="选择定时任务状态" clearable style="width: 150px;">
            <el-option label="失败" value="0"></el-option>
            <el-option label="成功" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
          <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 定时任务列表 -->
    <el-card class="table-card" shadow="never">
      <div slot="header" class="card-header">
        <span>定时任务列表</span>
        <div class="header-actions">
          <el-button type="primary" size="small" icon="el-icon-refresh" @click="loadTaskList">刷新列表</el-button>
        </div>
      </div>

      <configurable-table
        :columns="tableColumns"
        :data="filteredJobList"
        :loading="loading"
        :show-pagination="true"
        :current-page.sync="pagination.pageIndex"
        :page-size.sync="pagination.pageSize"
        :pagination-total="pagination.total"
        @page-change="loadTaskList"
        border
        stripe>
        <!-- 定时任务名称列 -->
        <template #jobName="{ row }">
          <div class="task-info">
            <span class="task-name">{{ row.jobName }}</span>
            <div class="task-desc">{{ row.taskDescription }}</div>
          </div>
        </template>

        <!-- 执行时间列 -->
        <template #cronExpression="{ row }">
          <el-tooltip :content="row.cronExpression" placement="top">
            <span class="cron-text">{{ row.cronDescription }}</span>
          </el-tooltip>
        </template>

        <!-- 定时任务状态列 -->
        <template #status="{ row }">
          <el-tag :type="getStatusTag(row.status)" size="small">
            {{ getStatusText(row.status) }}
          </el-tag>
        </template>

        <!-- 操作列 -->
        <template #actions="{ row }">
          <div class="action-buttons">
            <el-button
              v-if="row.status === 'stopped'"
              type="text"
              class="start-btn"
              @click="handleStartTask(row)">
              启动
            </el-button>
            <el-button
              v-if="row.status === 'running'"
              type="text"
              class="stop-btn"
              @click="handleStopTask(row)">
              停止
            </el-button>
            <el-button
              type="text"
              class="execute-btn"
              @click="handleExecuteTask(row)">
              立即执行
            </el-button>
            <el-button
              type="text"
              class="view-btn"
              @click="handleViewLog(row)">
              查看日志
            </el-button>
          </div>
        </template>
      </configurable-table>
    </el-card>

    <!-- 定时任务日志对话框 -->
    <el-dialog
      :visible.sync="logDialogVisible"
      width="900px"
      :close-on-click-modal="false"
      custom-class="log-dialog"
      :show-close="true"
      append-to-body>
      <div slot="title" class="dialog-title">
        <i class="el-icon-document"></i>
        <span>定时任务执行日志</span>
      </div>

      <div v-if="selectedTask" class="task-log">
        <div class="log-header-card">
          <div class="task-header-info">
            <div class="task-icon-wrapper">
              <i class="el-icon-s-operation"></i>
            </div>
            <div class="task-details">
              <h3 class="task-title">{{ selectedTask.jobName }}</h3>
              <p class="task-description">{{ selectedTask.taskDescription }}</p>
            </div>
          </div>
          <div class="task-meta">
            <div class="meta-item">
              <span class="meta-label">定时任务ID</span>
              <span class="meta-value">{{ selectedTask.jobId }}</span>
            </div>
            <div class="meta-item">
              <span class="meta-label">执行次数</span>
              <span class="meta-value">{{ selectedTask.executeCount || 0 }} 次</span>
            </div>
            <div class="meta-item">
              <span class="meta-label">状态</span>
              <el-tag :type="getStatusTag(selectedTask.status)" size="small" class="status-tag">
                {{ getStatusText(selectedTask.status) }}
              </el-tag>
            </div>
          </div>
        </div>

        <div class="log-section">
          <div class="log-section-header">
            <h4>
              <i class="el-icon-time"></i>
              执行历史记录
            </h4>
            <span class="log-count">共 {{ taskLogs.length }} 条记录</span>
          </div>

          <div class="log-content">
            <div
              class="log-item-card"
              :class="{'success-log': log.success, 'error-log': !log.success}"
              v-for="(log, index) in taskLogs"
              :key="index">
              <div class="log-item-header">
                <div class="log-index">
                  <span class="index-number">#{{ taskLogs.length - index }}</span>
                </div>
                <div class="log-status-badge" :class="log.success ? 'success' : 'error'">
                  <i :class="log.success ? 'el-icon-success' : 'el-icon-error'"></i>
                  <span>{{ log.success ? '执行成功' : '执行失败' }}</span>
                </div>
                <div class="log-time-wrapper">
                  <i class="el-icon-clock"></i>
                  <span class="log-time">{{ formatDateTime(log.executeTime) }}</span>
                </div>
              </div>
              <div class="log-item-body">
                <div class="log-message-wrapper">
                  <i class="el-icon-info"></i>
                  <div class="log-message">{{ log.message }}</div>
                </div>
              </div>
            </div>

            <div v-if="taskLogs.length === 0" class="empty-logs">
              <i class="el-icon-document-delete"></i>
              <p>暂无执行日志</p>
            </div>
          </div>
        </div>
      </div>

      <div slot="footer" class="dialog-footer-enhanced">
        <el-button @click="logDialogVisible = false" icon="el-icon-close">关闭</el-button>
        <el-button type="primary" @click="handleExecuteTask(selectedTask)" icon="el-icon-video-play">立即执行</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getScheduledJobList, getHistoryLog, startScheduledJob, stopScheduledJob, runScheduledJob } from '@/api/aggregation'

export default {
  name: 'ScheduledTask',
  data() {
    return {
      loading: false,
      searchForm: {
        jobName: '',
        status: ''
      },
      jobList: [],
      filteredJobList: [],
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      },
      jobStats: {
        running: 0,
        stopped: 0,
        error: 0,
        total: 0
      },
      logDialogVisible: false,
      selectedTask: null,
      taskLogs: [],
      // 表格列配置
      tableColumns: [
        { prop: 'jobId', label: '定时任务ID', minWidth: 80, align: 'center' },
        { prop: 'jobName', label: '定时任务名称', minWidth: 200, slot: 'jobName' },
        { prop: 'startTime', label: '执行时间', minWidth: 180, align: 'center', slot: 'startTime' },
        { prop: 'status', label: '定时任务状态', minWidth: 100, align: 'center', slot: 'status' },
        {
          prop: 'lastExecuteTime',
          label: '上次执行时间',
          minWidth: 160,
          align: 'center',
          formatter: (row) => this.formatDateTime(row.lastExecuteTime)
        },
        {
          prop: 'nextValidTime',
          label: '下次执行时间',
          minWidth: 160,
          align: 'center',
          formatter: (row) => this.formatDateTime(row.nextValidTime)
        },
        { prop: 'executeCount', label: '执行次数', minWidth: 100, align: 'center', sortable: true },
        { label: '操作', minWidth: 280, align: 'center', slot: 'actions' }
      ]
    }
  },
  created() {
    this.loadTaskList()
  },
  methods: {
    // 加载定时任务列表
    async loadTaskList() {
      try {
        this.loading = true
        const params = {
          pageIndex: this.pagination.pageIndex,
          pageSize: this.pagination.pageSize,
          ...this.searchForm
        }

        const response = await getScheduledJobList(params)
        if (response.code === 0) {
          this.jobList = response.data.list || []
          this.pagination.total = response.data.total || 0
          this.filteredJobList = [...this.jobList]
          this.calculateTaskStats(response.data)
          Logger.log('定时任务列表加载成功:', this.jobList)
        } else {
          this.$message.error(response.msg || '加载定时任务列表失败')
        }
      } catch (error) {
        Logger.error('加载定时任务列表失败:', error)
        // 模拟数据
        this.loadMockData()
      } finally {
        this.loading = false
      }
    },

    // 加载模拟数据
    loadMockData() {
      this.jobList = [
        {
          jobId: 1,
          jobName: '更新可提现金额',
          taskDescription: '每月15号凌晨12:00更新商家、业务员、区域代理可提现金额',
          startTime: '0 0 0 15 * ?',
          cronDescription: '每月15号 00:00',
          status: 0,
          lastExecuteTime: '2025-10-15 00:00:00',
          nextExecuteTime: '2025-11-15 00:00:00',
          executeCount: 12
        },
        {
          jobId: 2,
          jobName: '数据备份',
          taskDescription: '每日凌晨2:00进行数据备份',
          startTime: '0 0 2 * * ?',
          cronDescription: '每日 02:00',
          status: 1,
          lastExecuteTime: '2025-10-11 02:00:00',
          nextExecuteTime: '-',
          executeCount: 156
        },
        {
          jobId: 3,
          jobName: '清理过期日志',
          taskDescription: '每周日凌晨3:00清理30天前的日志文件',
          startTime: '0 0 3 ? * SUN',
          cronDescription: '每周日 03:00',
          status: 0,
          lastExecuteTime: '2025-10-12 03:00:00',
          nextExecuteTime: '2025-10-19 03:00:00',
          executeCount: 8
        }
      ]
      this.pagination.total = this.jobList.length
      this.filteredJobList = [...this.jobList]
      this.calculateTaskStats()
    },

    // 计算定时任务统计
    calculateTaskStats(data) {
      const list = data.list || []
      this.jobStats = {
        running: list.filter(job => job.status === 0).length,
        stopped: list.filter(job => job.status === 'stopped').length,
        error: list.filter(job => job.status === 1).length,
        total: data.total
      }
      Logger.log("计算定时任务统计", this.jobStats)
    },

    // 搜索
    handleSearch() {
      this.pagination.pageIndex = 1
      this.loadTaskList()
    },

    // 重置
    handleReset() {
      this.searchForm = {
        jobName: '',
        status: ''
      }
      this.pagination.pageIndex = 1
      this.loadTaskList()
    },

    // 启动定时任务
    async handleStartTask(task) {
      try {
        await this.$confirm(`确定要启动定时任务"${task.jobName}"吗？`, '确认启动', {
          type: 'warning'
        })

        const response = await startScheduledJob(task.jobId)
        if (response.code === 0) {
          this.$message.success('定时任务启动成功')
          this.loadTaskList()
        } else {
          this.$message.error(response.msg || '定时任务启动失败')
        }
      } catch (error) {
        if (error !== 'cancel') {
          Logger.error('启动定时任务失败:', error)
          this.$message.error('启动定时任务失败')
        }
      }
    },

    // 停止定时任务
    async handleStopTask(task) {
      try {
        await this.$confirm(`确定要停止定时任务"${task.jobName}"吗？`, '确认停止', {
          type: 'warning'
        })

        const response = await stopScheduledJob(task.jobId)
        if (response.code === 0) {
          this.$message.success('定时任务停止成功')
          this.loadTaskList()
        } else {
          this.$message.error(response.msg || '定时任务停止失败')
        }
      } catch (error) {
        if (error !== 'cancel') {
          Logger.error('停止定时任务失败:', error)
          this.$message.error('停止定时任务失败')
        }
      }
    },

    // 立即执行定时任务
    async handleExecuteTask(task) {
      try {
        await this.$confirm(`确定要立即执行定时任务"${task.jobName}"吗？`, '确认执行', {
          type: 'warning'
        })

        const response = await runScheduledJob({jobId: task.jobId})
        if (response.code === 0) {
          this.$message.success('定时任务执行成功')
          this.loadTaskList()
          // 如果日志弹框打开，刷新日志
          if (this.logDialogVisible) {
            this.loadTaskLogs()
          }
        } else {
          this.$message.error(response.msg || '定时任务执行失败')
        }
      } catch (error) {
        if (error !== 'cancel') {
          Logger.error('执行定时任务失败:', error)
          this.$message.error('执行定时任务失败')
        }
      }
    },

    // 查看日志
    handleViewLog(task) {
      this.selectedTask = task
      this.logDialogVisible = true
      this.loadTaskLogs()
    },

    // 加载定时任务日志
    async loadTaskLogs() {
      if (!this.selectedTask || !this.selectedTask.jobId) {
        Logger.warn('未选择定时任务或任务ID不存在')
        this.taskLogs = []
        return
      }

      try {
        Logger.log('开始加载定时任务详情和日志，jobId:', this.selectedTask.jobId)
        const response = await getHistoryLog({jobId: this.selectedTask.jobId})

        if (response.code === 0 && response.data) {
          const jobInfo = response.data

          // 处理执行日志列表
          const logs = jobInfo || []

          this.taskLogs = logs.map(log => ({
            executeTime: log.createTime || log.executeTime || log.startTime || '-',
            success: log.status === 0 || log.status === '0' || log.jobStatus === 0 || log.success === true,
            message: log.jobMessage || log.exceptionInfo || log.message || '执行完成'
          }))

          // 如果有其他任务信息需要更新，也可以在这里处理
          if (jobInfo.jobName) {
            this.selectedTask.jobName = jobInfo.jobName
          }
          if (jobInfo.jobGroup) {
            this.selectedTask.jobGroup = jobInfo.jobGroup
          }

          Logger.log('定时任务日志加载成功:', this.taskLogs)
        } else {
          Logger.warn('加载定时任务日志失败:', response.msg)
          this.$message.warning(response.msg || '加载定时任务日志失败')
          this.taskLogs = []
        }
      } catch (error) {
        Logger.error('加载定时任务日志异常:', error)
        this.$message.error('加载定时任务日志失败')
        this.taskLogs = []
      }
    },

    // 获取状态标签
    getStatusTag(status) {
      const statusMap = {
        1: 'success',
        0: ''
      }
      return statusMap[status] || 'default'
    },

    // 获取状态文本
    getStatusText(status) {
      const statusMap = {
        1: '成功',
        0: '失败'
      }
      return statusMap[status] || '未知'
    },

    // 格式化时间
    formatDateTime(dateTime) {
      if (!dateTime || dateTime === '-') return '-'
      return new Date(dateTime).toLocaleString()
    }
  }
}
</script>

<style scoped>
.app-container {
  padding: 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  color: white;
}

.header-left h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
}

.header-left p {
  margin: 0;
  opacity: 0.9;
  font-size: 14px;
}

.overview-cards {
  margin-bottom: 20px;
}

.overview-card {
  border-radius: 8px;
  overflow: hidden;
}

.overview-card.running {
  background: linear-gradient(135deg, #67c23a, #85ce61);
  color: white;
}

.overview-card.stopped {
  background: linear-gradient(135deg, #909399, #b1b3b8);
  color: white;
}

.overview-card.error {
  background: linear-gradient(135deg, #f56c6c, #f78989);
  color: white;
}

.overview-card.total {
  background: linear-gradient(135deg, #409eff, #66b1ff);
  color: white;
}

.card-content {
  display: flex;
  align-items: center;
  padding: 20px;
}

.card-icon {
  font-size: 32px;
  margin-right: 15px;
}

.card-info {
  flex: 1;
}

.card-value {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 5px;
}

.card-label {
  font-size: 14px;
  opacity: 0.9;
}

.search-card {
  margin-bottom: 20px;
}

.search-form {
  margin: 0;
}

.table-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-info {
  display: flex;
  flex-direction: column;
}

.task-name {
  font-weight: 500;
  color: #303133;
  margin-bottom: 4px;
}

.task-desc {
  font-size: 12px;
  color: #909399;
  line-height: 1.4;
}

.cron-text {
  font-family: monospace;
  font-size: 12px;
  color: #606266;
}

.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.start-btn {
  color: #67c23a;
}

.stop-btn {
  color: #f56c6c;
}

.execute-btn {
  color: #409eff;
}

.view-btn {
  color: #e6a23c;
}

/* ============ 定时任务日志弹框样式 ============ */

/* 弹框标题 */
.dialog-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

.dialog-title i {
  font-size: 20px;
  color: #409eff;
}

/* 定时任务日志容器 */
.task-log {
  padding: 0;
}

/* 日志头部卡片 */
.log-header-card {
  background: #f5f7fa;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.task-header-info {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e4e7ed;
  margin-bottom: 16px;
}

.task-icon-wrapper {
  width: 48px;
  height: 48px;
  background: #409eff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}

.task-details {
  flex: 1;
  min-width: 0;
}

.task-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-description {
  margin: 0;
  font-size: 13px;
  color: #606266;
  line-height: 1.5;
}

.task-meta {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-label {
  font-size: 12px;
  color: #909399;
}

.meta-value {
  font-size: 15px;
  font-weight: 600;
  color: #303133;
}

.status-tag {
  font-weight: 500;
}

/* 日志区域 */
.log-section {
  background: #fff;
}

.log-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f2f5;
}

.log-section-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-section-header h4 i {
  color: #409eff;
}

.log-count {
  font-size: 13px;
  color: #909399;
  background: #f4f4f5;
  padding: 4px 12px;
  border-radius: 12px;
}

/* 日志内容区域 */
.log-content {
  max-height: 450px;
  overflow-y: auto;
  padding-right: 4px;
}

/* 自定义滚动条 */
.log-content::-webkit-scrollbar {
  width: 6px;
}

.log-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.log-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.log-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 日志项卡片 */
.log-item-card {
  background: #ffffff;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.log-item-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.log-item-card.success-log {
  border-left: 4px solid #67c23a;
}

.log-item-card.error-log {
  border-left: 4px solid #f56c6c;
}

/* 日志项头部 */
.log-item-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #fafafa;
  gap: 12px;
}

.log-index {
  min-width: 50px;
}

.index-number {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  font-size: 14px;
  color: #909399;
  background: #f0f2f5;
  padding: 4px 10px;
  border-radius: 4px;
}

.log-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  min-width: 100px;
}

.log-status-badge.success {
  background: #f0f9ff;
  color: #67c23a;
  border: 1px solid #d4edda;
}

.log-status-badge.error {
  background: #fef0f0;
  color: #f56c6c;
  border: 1px solid #fde2e2;
}

.log-status-badge i {
  font-size: 14px;
  font-weight: bold;
}

.log-time-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: #909399;
  font-size: 13px;
}

.log-time-wrapper i {
  font-size: 14px;
}

.log-time {
  font-family: 'Courier New', monospace;
  font-weight: 500;
}

/* 日志项内容 */
.log-item-body {
  padding: 14px 16px;
}

.log-message-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.log-message-wrapper i {
  color: #409eff;
  font-size: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.log-message {
  flex: 1;
  color: #606266;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

/* 空日志状态 */
.empty-logs {
  text-align: center;
  padding: 60px 20px;
  color: #909399;
}

.empty-logs i {
  font-size: 64px;
  color: #dcdfe6;
  margin-bottom: 16px;
}

.empty-logs p {
  margin: 0;
  font-size: 14px;
}

/* 弹框底部 */
.dialog-footer-enhanced {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 0 0 0;
  border-top: 1px solid #e4e7ed;
}

/* 对话框底部样式已移至公共样式 dialog.scss */

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .overview-cards .el-col {
    margin-bottom: 15px;
  }

  .search-form {
    flex-direction: column;
  }

  .search-form .el-form-item {
    margin-right: 0;
    margin-bottom: 15px;
  }

  .action-buttons {
    flex-direction: column;
    gap: 4px;
  }

  /* 日志弹框响应式 */
  .log-header-card {
    padding: 16px;
  }

  .task-header-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-icon-wrapper {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .task-title {
    font-size: 18px;
  }

  .task-meta {
    flex-direction: column;
    gap: 12px;
  }

  .log-item-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .log-time-wrapper {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .log-status-badge {
    min-width: auto;
  }

  .index-number {
    font-size: 12px;
    padding: 3px 8px;
  }
}
</style>
